package org.example.config;


import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import dev.langchain4j.store.memory.chat.InMemoryChatMemoryStore;
import org.example.bean.ChatMessages;
import org.example.store.MongoChatMemoryStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SeparateChatAssistantConfig {

    @Autowired
    private MongoChatMemoryStore mongoChatMemoryStore;

    @Bean
    public ChatMemoryProvider chatMemoryProvider(){
        //通过列表的形式实现
      //  return memoryId -> MessageWindowChatMemory.builder().id(memoryId).maxMessages(10).build();

          return memoryId -> MessageWindowChatMemory
                  .builder()
                  .id(memoryId)
                  .maxMessages(10)
//                  .chatMemoryStore(new InMemoryChatMemoryStore())
                  .chatMemoryStore(mongoChatMemoryStore)
                  .build();
    }


}
